﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SmartSpace.Core;
using Microsoft.Win32;
using System.IO;

namespace SsTool.Core.Windows
{
    /// <summary>
    /// Interaction logic for ThemeWindow.xaml
    /// </summary>
    public partial class ThemeWindow : Window
    {
        private SmartSpace.Core.Theme _theme;

        public ThemeWindow()
        {
            InitializeComponent();

            _theme = new SmartSpace.Core.Theme();
            _theme.Id = Guid.NewGuid();
            _theme.Name = string.Format("新主题{0}", _theme.Id);
            this.DataContext = _theme;
        }

        public ThemeWindow(SmartSpace.Core.Theme theme)
        {
            InitializeComponent();
            _theme = theme;
            this.DataContext = _theme;
        }

        private void _ctlBtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            ICoreService service = App.Get<ICoreService>();
            if (service.SaveTheme(_theme))
            {
                DialogResult = true;
            }
            else
            {
                MessageBox.Show("保存失败!");
            }
        }

        private void _ctlBtnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
